﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LiveSequence.Interface;

namespace LiveSequence.Suite.Documents
{
  public class BaseDoc : IDocument
  {
    protected string _strTitle;
    protected bool _bIsDirty;
    

    #region IDocument Members

    public event EventHandler UpdateView;
    public event EventHandler IsDirtyChanged;
    public event EventHandler TitleChanged;
    public event EventHandler Closed;

    public string Title
    {
      get
      {
        return _strTitle;
      }
      set
      {
        _strTitle = value;
        OnTitleChanged();
      }
    }

    public virtual void OnTitleChanged()
    {
      if(TitleChanged!=null)
      {
        TitleChanged(this, EventArgs.Empty);
      }
    }

    public bool IsDirty
    {
      get
      {
        return _bIsDirty;
      }
      set
      {
        _bIsDirty = value; 
        OnIsDirtyChanged();
      }
    }

    public virtual void OnIsDirtyChanged()
    {
      if(IsDirtyChanged != null)
      {
        IsDirtyChanged(this, EventArgs.Empty);
      }
    }

    public virtual void OnUpdateAllViews(IView view, object param)
    {
      if(UpdateView != null)
      {
        UpdateView(null, EventArgs.Empty);
      }
    }
    #endregion
  }
}
